package com.loanly.view;

import java.util.List;

import com.loanly.controller.LoginManager;
import com.loanly.model.Login;
 
import com.opensymphony.xwork2.ActionSupport;
 
 
public class LoginAction extends ActionSupport {
 
    private static final long serialVersionUID = 9149826260758390091L;
    private Login login;
    private List<Login> loginList;
    private Long loginid;
 
    private LoginManager loginManager;
 
    public LoginAction() {
    	loginManager = new LoginManager();
    }
 
    public String execute() {
        this.loginList = loginManager.list();
        System.out.println("LoginAction execute called");
        return SUCCESS;
    }
 
    public String add() {
        System.out.println(getLogin().getActive());
        System.out.println(getLogin().getFirstname());
        try {
        	loginManager.add(getLogin());
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.loginList = loginManager.list();
        return SUCCESS;
    }
 
    public String delete() {
    	loginManager.delete(getLoginId());
        return SUCCESS;
    }
 
    public Login getLogin() {
    	//System.out.println("login��firstname == " + login.getFirstName());
        return login;
    }
 
    public List<Login> getLoginList() {
        return loginList;
    }
 
    public void setLogin(Login login) {
        this.login = login;
    }
 
    public void setLoginList(List<Login> loginsList) {
        this.loginList = loginsList;
    }
 
    public Long getLoginId() {
        return loginid;
    }
 
    public void setId(Long loginid) {
        this.loginid = loginid;
    }
}